<template>
  <a-modal
    :title="title"
    :width="width"
    :visible="visible"
    :footer="null"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-card >
          <span slot="title" >
              工单号:{{record.woNo}}
          </span>
          <span slot="extra" >
          状态:
            <span v-if="record.ioflag=='1'"><a-tag color="red">未推送</a-tag></span>
            <span v-if="record.ioflag!='1'&&record.ioflag!=0"><a-tag color="red">推送错误</a-tag></span>
            <span v-if="record.ioflag=='0'"><a-tag color="green">已推送</a-tag></span>
          </span>
        <a-steps :current="current" size="small" labelPlacement="vertical">
          <a-step title="创建"  />
          <a-step title="原材料实验" />
          <a-step title="生产中" />
          <a-step title="出场实验"  />
          <a-step title="包装入库"  />
        </a-steps>
      </a-card>
      <a-card>
        <span slot="title" >
              生产订单详情
          </span>
        <div>
          <a-row>
            <a-col :span="3">采购总部编码:</a-col>
            <a-col :span="5">{{record.purchaserHqCode}}</a-col>
            <a-col :span="3">生产订单编号:</a-col>
            <a-col :span="5">{{record.ipoNo}}</a-col>
            <a-col :span="3">供应商编号:</a-col>
            <a-col :span="5">{{record.supplierCode}}</a-col>
          </a-row>
          <a-row>
            <a-col :span="3">工单号:</a-col>
            <a-col :span="5">{{record.woNo}}</a-col>
            <a-col :span="3">品类编码:</a-col>
            <a-col :span="5">{{record.categoryCode}}</a-col>
            <a-col :span="3">种类编码:</a-col>
            <a-col :span="5">{{record.subclassCode}}</a-col>
          </a-row>
          <a-row>
            <a-col :span="3">物料编码:</a-col>
            <a-col :span="5">{{record.materialsCode}}</a-col>
            <a-col :span="3">物料描述:</a-col>
            <a-col :span="5">{{record.materialsDescription}}</a-col>
            <a-col :span="3">物料批次:</a-col>
            <a-col :span="5">{{record.materialsBatch}}</a-col>
          </a-row>
          <a-row>
            <a-col :span="3">实物ID:</a-col>
            <a-col :span="5">{{record.productId}}</a-col>
            <a-col :span="3">物料数量:</a-col>
            <a-col :span="5">{{record.amount}}</a-col>
            <a-col :span="3">单位:</a-col>
            <a-col :span="5">{{record.unit}}</a-col>
          </a-row>
          <a-row>
            <a-col :span="3">计划开始时间:</a-col>
            <a-col :span="5">{{record.planStartDate}}</a-col>
            <a-col :span="3">计划完成时间:</a-col>
            <a-col :span="5">{{record.planFinishDate}}</a-col>
            <a-col :span="3">实际开始时间:</a-col>
            <a-col :span="5">{{record.actualStartDate}}</a-col>
          </a-row>
          <a-row>
            <a-col :span="3">实际结束时间:</a-col>
            <a-col :span="5">{{record.actualFinishDate}}</a-col>
            <a-col :span="3">工艺路线编码:</a-col>
            <a-col :span="5">{{record.processRouteNo}}</a-col>
            <a-col :span="3">数据来源:</a-col>
            <a-col :span="5">{{record.dataSource}}</a-col>
          </a-row>
          <a-row>
            <a-col :span="3">数据创建时间:</a-col>
            <a-col :span="5">{{record.dataSourceCreateTime}}</a-col>
            <a-col :span="3">是否推送:</a-col>
            <a-col :span="5"><span v-if="record.ioflag==1">未推送</span><span v-if="record.ioflag==0">已推送</span></a-col>
            <a-col :span="3">推送时间:</a-col>
            <a-col :span="5">{{record.pushTime}}</a-col>
          </a-row>
          <a-row>
            <a-col :span="3">更新方式:</a-col>
            <a-col :span="5"><span v-if="record.status==1">更新</span><span v-if="record.status==0">新增</span></a-col>
            <a-col :span="3">监造标志:</a-col>
            <a-col :span="5"><span v-if="record.supervisionFlag==1">是</span><span v-if="record.supervisionFlag==0">否</span></a-col>
            <a-col :span="3">产品规格:</a-col>
            <a-col :span="5">{{record.modelSpec}}</a-col>
          </a-row>
          <a-row>

            <a-col :span="3">交易流水号:</a-col>
            <a-col :span="5">{{record.transno}}</a-col>
            <a-col :span="3">错误信息:</a-col>
            <a-col :span="5">{{record.message}}</a-col>
            <a-col :span="3"></a-col>
            <a-col :span="5"></a-col>
          </a-row>
        </div>
      </a-card>


    </a-spin>
  </a-modal>
</template>

<script>

  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import JDate from '@/components/jeecg/JDate'
  import ARow from 'ant-design-vue/es/grid/Row'
  import ACol from 'ant-design-vue/es/grid/Col'
  
  export default {
    name: "ZxjEipGdModal",
    components: {
      ACol,
      ARow,
      JDate,
    },
    record:{},
    data () {
      return {
        form: this.$form.createForm(this),
        title:"操作",
        width:800,
        current:0,
        visible: false,
        model: {},
        url: {
          add: "/zxEipGd/zxjEipGd/add",
          edit: "/zxEipGd/zxjEipGd/edit",
        }
     
      }
    },
    created () {
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'purchaserHqCode','ipoNo','supplierCode','woNo','categoryCode','subclassCode','materialsCode','materialsDescription','materialsBatch','productId','amount','unit','planStartDate','planFinishDate','actualStartDate','actualFinishDate','woStatus','processRouteNo','dataSource','dataSourceCreateTime','isDeleted','ioflag','message','status','transno','workId','openId','ownerId','modelSpec','supervisionFlag','pushTime'))
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            console.log("表单提交数据",formData)
            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }
         
        })
      },
      handleCancel () {
        this.close()
      },
      popupCallback(row){
        this.form.setFieldsValue(pick(row,'purchaserHqCode','ipoNo','supplierCode','woNo','categoryCode','subclassCode','materialsCode','materialsDescription','materialsBatch','productId','amount','unit','planStartDate','planFinishDate','actualStartDate','actualFinishDate','woStatus','processRouteNo','dataSource','dataSourceCreateTime','isDeleted','ioflag','message','status','transno','workId','openId','ownerId','modelSpec','supervisionFlag','pushTime'))
      },
      addModal (record) {
        this.record=record;
        this.visible = true;
        if(record.woStatus){
          this.current=parseInt(record.woStatus)-1
        }else{
          this.current=0
        }

      }
      
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
  .ant-card.ant-card-bordered {
    margin-top: 3px;
  }
  .ant-row{
    margin-top: 13px;
  }
</style>